added count check to inventory.js