writing handshake