Update the redirect listener to redirect only when needed