bug with bad middleware fixed