refactored code for model controllers