fixed database error (not tested)