Fix for TooManyRedirects error