       (Integer/parseInt)
       (/ 10)))
 
-(defn get-parent-id
-  [indent-level reply-levels]
-  (if (= indent-level 0)
-    nil
-    (get reply-levels (dec indent-level))))
-
-(defn rm-nil-bulb
-  [reply]
-  (if (nil? (:bulbs reply))
-    (dissoc reply :bulbs)
-    reply))
-
-(defn rm-nil-parent-id
-  [reply]
-  (if (nil? (:parent-id reply))
-    (dissoc reply :parent-id)
-    reply))
-
-(defn rm-nil-keys
-  [reply]
-  (-> reply
-      (rm-nil-bulb)
-      (rm-nil-parent-id)))
-
-;(defn combine-users
-;  [thread-data user bulb-users]
-;  (let [users (:users thread-data)]
-;    (-> users
-;        (union (into #{} (list user)))
-;        (union bulb-users))))
-;
-;(defn combine-replies
-;  [thread-data reply]
-;  (->> reply
-;       (rm-nil-keys)
-;       (list)
-;       (into (:replies thread-data))))
-;
-;(defn update-thread-data
-;  [thread-data replies users]
-;  (-> thread-data
-;      (assoc :replies replies)
-;      (assoc :users   users)))
-
-;(defn get-data-helper
-;  [row]
-;  (let [cols           (utils/get-cols       row)
-;        reply-url      (get-reply-url        cols)
-;        reply-id       (get-reply-id         reply-url)
-;        reply-title    (get-reply-title      cols)
-;        post-time      (get-reply-post-time  cols)
-;        reply          {:id         reply-id}]))
+(defn get-reply-data
+  [cols id bulbs]
+  (let [user  (get-reply-user cols)
+        reply {:id    id
+               :title (get-reply-title cols)
+               :time  (get-reply-post-time cols)
+               :user  (:id (first user))}
+        bulbs (dissoc bulbs :users)]
+    (if (empty? bulbs)
+      {:reply reply
+       :user  user}
+      {:reply (assoc reply :bulbs bulbs)
+       :user  user})))
 
 (defn get-thread-data
   [row]

       (PhantomJSDriver.
         (doto (DesiredCapabilities.)
           (.setCapability "phantomjs.binary.path" phantomjs-path)
           (.setCapability "phantomjs.page.settings.loadImages" false)))})))

(defn get-data
  ([url]

        id        (get-reply-id reply-url)
        indent    (get-indent-level cols)
        bulbs     (bulbs/get-data reply-url)
        rdata     (get-reply-data cols id bulbs)
        reply     (:reply rdata)
        user      (:user rdata)
        users     (into (get bulbs :users) user)
        parents   {indent id}]
    {:replies (vec (list reply))
     :users   (set users)
     :parents parents}))

(defn get-parent
  [curr parents]
  (let [indent   (ffirst (:parents curr))
        parent   (get parents (dec indent))
        replies  (assoc (first (:replies curr)) :parent parent)]
    (assoc curr :replies (vec (list replies)))))

(defn my-reducer
  [new-map curr]
  (let [parents (:parents new-map)
        ncurr   (get-parent curr parents)]
    (merge-with into new-map ncurr)))

(defn get-data-by-url
  [url]
  ; {:browser :firefox :profile bo-ffprofile}

  (let [table     (get-replies-table url)
        rows      (utils/get-rows table)
        thread-id (get-thread-id url)
        data      (map get-thread-data rows)
        comb-data (reduce my-reducer {} data)]
    comb-data
    ; data
    ))
