rearranged some stuff, added exit at the end of telnet