fix middle ware