change iterator to indexedseq in order to be reused