         ; reset only after something was found
         (reset! nonfts-results []))
 
+      (reset! nonfts-keys
+              (union @nonfts-keys (set (map #(key (second %)) new-results))))
+
       (reset!
         nonfts-results
         (concat @nonfts-results new-results))
 
       (if (or (and reset (empty? new-results))
-              (< (count @nonfts-results) 100))
+              (< (count @nonfts-results) 2000))
         (reset! query-immediate
                 (.setImmediate js/window
                                #(do-match-chunks
                                  query
-                                 (and reset (= 0 (count new-results)))))))))
+                                 (and reset (= 0 (count new-results)))
+                                 (> (count @nonfts-results) 100)))))))
 
   (if (and (empty? @nonfts-cursor) reset)
     (reset! nonfts-results []))
 
-  (if (or (empty? @nonfts-cursor)
-          (>= (count @nonfts-results) 8))
+  (if (and (not just-for-next-queries)
+           (or (empty? @nonfts-cursor)
+               (>= (count @nonfts-results) 8)))
     ; show only after finished searching or if found at least 8 results,
     ; to avoid flickering of the list
     (reset!


        @score))))

(defn do-match-chunks [query reset]
  (if (not-empty @nonfts-cursor)
    (let [chunk (first @nonfts-cursor)
          new-results
          (->>
            chunk
            (map (fn [v] [(score-exact (.-name (.-contents v)) query) v]))
            (filter #(> (first %) 0))
            (take 100))]

(defn match-chunks [entries query]
  (if (not (nil? @query-immediate))
    (.clearImmediate js/window @query-immediate))
  (reset! nonfts-cursor (cons (map #(second %) @nonfts-results)
                              (partition-all 2000 entries)))
  (reset! nonfts-keys #{})
  (do-match-chunks query true false) 0)

(defn set-query [q]
  (reset! query q)
