completed Pairwise Algorithm