fix broken middleware