Fixed the math thanks to Algorithman