fixed bugs in db