controller refactoring