modify the Training logic