created modify_training_data function
refactored a bunch of code