made changes to train.m