Corrected default middleware implementation