Refactor to use tty stream