Fixed the bug with incorrect calculations, but oh it's goddamn slow now