Implemented most of MainController