Added midpoint calc