use Hash interface for iterating keys

see: #2202