Added conditions to redirection function in client handler