refactorize redirection