fix to middlware