corrected generate_training for borderline cases