replace forEach with standard for loop