refactoring legacy controller