moved functions from controller to manager