@idontgnu: Then the algorithm