clean the middleware