better follow redirects algorithm