the algorithm worked