Refactor inventory to remove dulplicated code.