finish train func