@saebekassebil: did you find the bug in this algorithm?