refactor map iterator