fix bug about redirection when error