corrected middleware