Better use of iterators