refactors for loops to forEach