updated hash_for_each_safe functions