replace deprecated escape() with encodeURIComponent()