changed rng, optimised sampleEM