Ar, I’ve just seen it:
end performSmartRule needs to go after end tell rather than after end urlencode
end performSmartRule
end tell
end urlencode