Refactor and add mathcheck

Localize variable.