fix ema number of terms problem