finished main refactor