refactoring main file