Extracted midpoint calculator helpers to module