Use iterators instead of indices