update database and fixed some bugs