refactored the controllers