replaced for loop with forEach