addToGrocery and addToInventory now use the same helper function