fix math bug