Implementation of EMAS algorithm