fix in training function