Replaced the controller from a function to an actual controller