WIP: implementing handshake