fixed bugs in math type checking