fixed input redirection, need to fix output