fixed isatty handling