fix some bugs on delete but there are some new bugs not fixed