refactoring: change order of functions