Fix midpoint value bug