cleanup code using set operations