fixed ordering of redirecting middleware