Fix adding middleware