fixed bug in smoothing() function