Fixing database error