refactor of MainViewController