added error handling and fixed user->db problem.