fix redirection bugs