fixed some bugs after changing database