Refactor iterator.