more robust url handling