Moved logic from controller classes into a service class