added function to smooth the time series