fixed memory leak in the inventory