Finally got math to behave