make the code for reseeding the generator more robust