Adding handshake functionality