Replaced custom next function with iterator.