added emd code