Method for treating a substrate