Refactor the controllers