refactoring and code organization