Refactor handshake lookup