Refactoring of main class