refactor iterate