updated error page middleware