defensive against memory leaks