Refactored the controllers