Trying to link ends of segments