fix the middleware.