Fix middleware order