updated example with key exchange