Added better math parsing logic