added middleware reversal