refactored main class