refactor iterator