Added conditional seeding to random number generation