cleaned up the math.