for loop refactoring