Algorithm(8)