changed for loop