reduce memory usage of set operations