 
                 } else {
                     endCoordinates[lineString[i]] = 1
+                    endCoordinatesOrdered.append(lineString[i])
                 }
 
                 i = lineString.count - 1


                } else {
                    endCoordinates[lineString[i]] = 1
                }
            }
        }

        var boundary = MultiPoint(precision: self.precision, coordinateSystem: self.coordinateSystem)

        for (coordinate, count) in endCoordinates {
            if count % 2 == 1 {
                boundary.append(Point(coordinate, precision: self.precision, coordinateSystem: self.coordinateSystem))
            }
        }
        return boundary

    public func boundary() -> Geometry {

        var endCoordinates = [Coordinate: Int]()
        var endCoordinatesOrdered = [Coordinate]()

        for i in 0 ..< self.count {
            let lineString = self[i]
