using a better isDone pattern for generators