fixed algorithm for stitching together inner and outer polygon segments