refactored some code in controllers