more refactoring for controller