fixed some errors with redirection