Changed for loop to each