initial key syncing code