Finished For loop to calculate averages