Work on the algorithm