Resolve redirection logic issues