Add midpoint method in midWay function