To elaborate, the problem is that the hash is recreated each time, which means the internal iterator is also recreated each time. The same behavior will show up for keys() and values(), as well.
My criteria for good software:
Does it work?
Can someone else come in, make a change, and be reasonably certain no bugs were introduced?