fixed the redirect function as well as an error message in case of redirection fail...