Changed .each to for loops.