Refactored to make use of inventory variables