Figure 4: Flowchart of the algorithm.