refactoring in controllers