replaced for loop with step loop