changed to use the iter() function instead of returning a generator