figured out that algorithm
figured out that algorithm