use encodeURI instead of string replace