made the redirection code a little more beautiful