smoothing
extracted smoothing function