loop style refactoring and renaming