fixing bug in train_mm