Modified the FindNearestPoly function