Rewrite track_inventories to use set operations