using the midpoint formula