in reply to a global hash?

Note that my %heap_hash; would work just as well in the code you posted.