* hmmmm, the algorithm posted isn't exactly correct per se