ensure that the generator is valid before calling next