fixed an array index bug around training