refactoring inventory stuff into inventory.js