refactoring main class