The algorithm u proposed is somthing i was thinking too, but i wasnt sure about it.
I think ur answer is ok, ty for the help .