add smoothing function