initial implementation of i/o redirection
some changes