             (let [j (inc i)]
               (reduce (fn [ds [D m]] (spin ds i j D (/ m (r ds i j D))))
                       ds
-                      (filter (fn [[D m]] (> m 0))
+                      (filter (fn [[D m]] (and (r ds i j D) (> m 0)))
                               (zipmap (orbit-reps ds [i j]) (nth spins i))))))
           ds
           (range (count spins))))

(defmulti dsymbol class)

(defn- parse-numbers [str]
  (map #(Integer/parseInt %) (-> str s/trim (s/split #"\s+"))))

(defn- parse-number-lists [str]
  (map parse-numbers (-> str s/trim (s/split #","))))

(defn- pairs [data free]
  (when (seq free)

         (DSymbol. 2 2
                   {0 {1 2, 2 1} 1 {1 1, 2 2} 2 {1 2, 2 1}}
                   {0 {1 2, 2 2} 1 {1 3, 2 3}})))
  (is (= (dsymbol "1.1:2:2,1 2,2:4,6")
         (DSymbol. 2 2
                   {0 {1 2, 2 1} 1 {1 1, 2 2} 2 {1 2, 2 1}}
                   {0 {1 2, 2 2} 1 {1 3, 2 3}})))
  (is (= (dsymbol "2:2,1 2,2:4,6")
         (DSymbol. 2 2
                   {0 {1 2, 2 1} 1 {1 1, 2 2} 2 {1 2, 2 1}}
                   {0 {1 2, 2 2} 1 {1 3, 2 3}})))
  (is (= (dsymbol "2:2,,2:4,6")
         (DSymbol. 2 2
                   {0 {1 2, 2 1} 2 {1 2, 2 1}}
                   {})))
  (is (= (dsymbol "<1.1:2:2,1 2,2:4,5>") nil))
  (is (= (dsymbol "<1.1:2:2,1 2,2:0,6>")
         (DSymbol. 2 2
                   {0 {1 2, 2 1} 1 {1 1, 2 2} 2 {1 2, 2 1}}
                   {1 {1 3, 2 3}})))
  (is (= (dsymbol "<1.1:2:2,1 2,2:4,>")
         (DSymbol. 2 2
                   {0 {1 2, 2 1} 1 {1 1, 2 2} 2 {1 2, 2 1}}
                   {0 {1 2, 2 2}})))
  (is (= (dsymbol "<1.1:2:2,1 2,2:>")
         (DSymbol. 2 2
                   {0 {1 2, 2 1} 1 {1 1, 2 2} 2 {1 2, 2 1}}
                   {})))
  (is (= (dsymbol "<1.1:2:2:>")
         (DSymbol. 2 2
                   {0 {1 2, 2 1}}
                   {})))
  (is (= (dsymbol "<1.1:2>")
         (DSymbol. 2 2
                   {}
                   {})))
  )
