Optimizing data generation