FIX:Fixed bugs in nearest to endpoint strategy