corrected generate_training