updated all for loops to use forEach method instead