updating math logic