better handling of deleting objects