fix some bugs in db