@dantheman: The algorithm