First working version of EM