Does this return the URL, or the smart proxy object?  The code below assumes a URL.