for loop rework