started refactor of controller