Discovered better algorithm

Still needs cleaning now that i have a mod method