fix the db bugs