Added check for tty