Tweaked the algorithm
Revert "Tweaked the algorithm"

This reverts commit 3c3b69845bc3c27388a016ebe430ba2d379e342e.
Checkpoint