finished cross validation function, adapted it to time series data