fix bugs with delete