HOPKINS: Refactor inventory code