work on ema
implemented ema, passing tests