replace forEach with for