patch for the smoothing function of the previous commit