Improve database logic and UserController logic