fix before middleware precedence