Fix handshake function

Signed-off-by: David Scott <dave.scott@eu.citrix.com>