Moved functions to user controller