replace math.math with ternary