Refactoring Main class