 		if (!initialized)
 			initialize();
 		
+		var methodName:String = methodInfo.name;
+		method = host[methodName];
+		
 		// backwards compatibility
 		if (!json)
 		{
-			ExternalInterface.addCallback(methodInfo.name, host[methodInfo.name]);
+			ExternalInterface.addCallback(methodName, method);
 			return;
 		}
 		
-		var methodName:String = methodInfo.name;
-		method = host[methodName];
 		// find the number of required parameters
 		paramCount = 0;
 		while (paramCount < method.length && !methodInfo.parameters[paramCount].optional)

			
			// if there are no parameters, just run the code
			if (pNames.length == 0)
				return ExternalMethod.fixed_ExternalInterface_call(code);
			
			// call the function with the specified parameters
			pValues.unshift(code);

		var result:* = em.method.apply(null, params);
		var resultJson:String = json.stringify(result, _jsonReplacer);
		
		// work around flash player bug
		if (backslashNeedsEscaping)
			resultJson = resultJson.split('\\').join('\\\\');

		return resultJson;
