minor refactoring in controller