Refactored controller class