refactors view handling on main controller.