fix strange behavior during redirection