Re-introduced the handshake logic