function structure refactoring