extract escape path to middleware