added train func