fixing some bugs in inventory management