added support for IO redirection