fix math function