updated train.m