got rid of midpointNext function