Fixed math errors