refactoring and reordering