Removed functions from the controller classes and moved them to the model classes