Updates the doMath method to remove redundancy.