fix middleware