main class refactor