refactor main class