refactoring controller