Figure 6 Algorithm 2.