Fix bug of delete logic