refactored some methods used in controllers