                 let color = CARGBColor(r: CGFloat(data[index]) / 255,
                                        g: CGFloat(data[index+1]) / 255,
                                        b: CGFloat(data[index+2]) / 255)
-                colorSet.add(color)
-                if row==0 || row==height-1 || col==0 || col==width-1 {
-                    edgeColorSet.add(color)
+                if color.isDark != isDarkBackground {
+                    colorSet.add(color)
                 }
             }
         }
         
         let colors = colorSet.objectEnumerator().allObjects.flatMap() { color -> CACountedRGBColor? in
-            guard let rgbColor = color as? CARGBColor else {
-                return nil
-            }
-            let count = colorSet.count(for: rgbColor)
+            let color = color as! CARGBColor
+            let count = colorSet.count(for: color)
             if count > 2 {
-                return CACountedRGBColor(color: rgbColor, count: count)
+                return CACountedRGBColor(color: color, count: count)
             } else {
                 return nil
             }
         }
         
-        let edgeColors = edgeColorSet.objectEnumerator().allObjects.flatMap() { color -> CACountedRGBColor? in
-            guard let rgbColor = color as? CARGBColor else {
-                return nil
-            }
-            let count = edgeColorSet.count(for: rgbColor)
-            if count > 2 {
-                return CACountedRGBColor(color: rgbColor, count: count)
-            } else {
-                return nil
-            }
-        }
-        
-        return (colors, edgeColors)
+        return colors
     }
     
     func findEdgeColor(in edgeColors: [CACountedRGBColor]) -> CARGBColor? {

        }
        
        backgroundColor = background.cgColor
        primaryColor = textColors.primary?.cgColor ?? fallback
        secondaryColor = textColors.secondary?.cgColor ?? fallback
        detailColor = textColors.detail?.cgColor ?? fallback
    }
    
    public func analyze(completionHandler: () -> Void) {

    }
    
    public func analyze() {
        guard let edgeColors = findEdgeColors(),
            let background = findEdgeColor(in: edgeColors) else {
            return
        }
        
        let colors = findColors(isDarkBackground: background.isDark)
        let textColors = colors.flatMap() { findTextColor(in: $0, background: background) }
        
        let fallback:CGColor
        if background.isDark {
