refactor to make some iterators smaller in release mode