changing to for loops