Fix bug in definition of hashes within a loop