trying to tidy up terminal.js a bit