docs here too describing the algorithm