added code for handshake