restructure: refactor mainController