Refactor executeJavascript()