Refactored main class