Changed for statements to forEach

Some of the loops were throwing errors because the loop was going 1 past the length of the array.  forEach will only loop for each array index