fix redirecting in error functions