fixed bugs in database