Solved index out of bounds error in trainer.cpp