refactored controller class