 (defn add-client-to-query [query  client-id]
   (let [
         existing-query     (get @cached-queries   query)
-        existing-clients   (get @query           :clients)
+        existing-clients   (get @existing-query  :clients)
         ]
-        (swap! existing-clients assoc client-id
-        )))
+        (swap! existing-clients conj client-id)
+        ))
 
 
 

                     (println (str "    " "Query"))
                     (println (str "    " query))
                     (println (str "    "))
                     (println (str "    " "Before"))
                     (println (str "    " @(get @cached-queries query)))

                     (update-query-in-cache  query)

                     (println (str "    "))
                     (println (str "    " "After"))
                     (println (str "    " @(get @cached-queries query)))
                     (println (str "    "))
                     ))))))))


      (println (str "    " query))

      (if (not existing-query)
        (swap! cached-queries assoc  query (atom {:clients  (atom #{})})))


      (let [the-query        (get @cached-queries   query)
            ]
        (swap! the-query assoc  :records       result-id-vector)
        (swap! the-query assoc  :count         record-count)
        (swap! the-query assoc  :timestamp    (java.util.Date.))
        ))))

