fix math errors