beginning pairing algorithm v3