remove escapeAndEncode, replace with encodeURIComponent where appropriate