refactoring using binmode to STDIN, STDOUT, SDTERR