update database and fix bug