Sped the calculation up by using the dirtiest hack I've ever written.