fix crashing on inventory reading