fixed crash if database has wrong record