updated and fixed em derivation