Fixed bug while deleting objects