referenced algorithm 3.2 in section 5