         
         // top left and right corners of each view
         // sorted from left to right, top to bottom
-        var topPoints:[CGPoint] = frames.reduce([]) { $0 + [$1.topLeft, $1.topRight] }
+        var topPoints:[CGPoint] = frames.topPoints
         topPoints = topPoints.sorted(by: { $0.x == $1.x ? $0.y < $1.y : $0.x < $1.x })
         
         // trace top line from left to right

    }
}

extension UIBezierPath {
    
    //code adapted from http://stackoverflow.com/a/35711310/1138900

        
        // botom left and right corners of each view
        // sorted from right to left, bottom to top
        var bottomPoints: [CGPoint] = frames.bottomPoints
        bottomPoints = bottomPoints.sorted(by: { $0.x == $1.x ? $0.y > $1.y : $0.x > $1.x })
        
        // trace bottom line from right to left
