replaces the middleware