Use iterators instead of positional index loop