fixed some bug in database