     }
     
     func findTextColor(in colors: [CACountedRGBColor], background: CARGBColor) -> (primary: CARGBColor?, secondary: CARGBColor?, detail: CARGBColor?) {
-        let colors = colors.filter(){ $0.count > 1 }.sorted() { $0.count > $1.count }
+        let colors = colors.filter(){
+            $0.color.isContrastable(with: background)
+        }.sorted() {
+            $0.count > $1.count
+        }
         
         var primary: CARGBColor? = nil
         var secondary: CARGBColor? = nil

        
        for countedColor in colors {
            let color = countedColor.color
            guard color.isContrastable(with: background) else {
                continue
            }
            guard let c1 = primary else {
                primary = color
                continue

    
    func findEdgeColor(in edgeColors: [CACountedRGBColor]) -> CARGBColor? {
        let threshold = edgeColors.count / 50
        let colors = edgeColors.filter(){
            $0.count > threshold
        }.sorted() {
            $0.count > $1.count
        }
        
        guard colors.count > 0 else {
            return nil
