fix middlewares