updated smoothing function