Improve performance by running code related to the inventory only when the inventory changes