changed for loops