Refactoring complex controller