instead of setting counter and incrementing it, we can use ruby index methods

e.g.
[1,2].collect.with_index do |x, index| p x; p index end
[1,2].each_with_index do |x, index| p x; p index end

This is nice to have.