Implementation of EMA