move controller private functions into model methods