Replace for-in loops with for loops