Optimized Forecast code