fix middleware.