fixed bugs in Database