fix bugs in redirects