Added lots of code to the controller.