moved some switch statements in EM engine to separate functions