Fixed the algorithm. Realized I had it wrong in the original commit. This one takes longer. Have fun!