Replaced forEach with for loops.