Added optimization algorithm of forecast function