iterator and generator versions implemented