fix bugs in database