refactoring main