fixed usage of iterators