bug fix in db.c