Convert the for loop to use each on an array from a range