fixed bug when deleting objects