Implemented significantly better algorithm
v2.0.0