Moved some functionality to the controller