Corrected middleware