Changed for loops to .each

I changed the for loops in the model to .each as they are preferred.