switch read() to use iterators