added some handshaking type stuff