using iterators to do the sum