fixed DB bugs