             pos (+ start i)]
           (m "li" nil [(m "button" {:onclick #(edit item pos)} "Edit")
                        title])))
-    (subvec data start (+ start PAGESIZE))))
+    (if (< PAGESIZE (count data))
+      (subvec data start (+ start PAGESIZE))
+      data)))
 
 (defn page [start direction count]
   (let [next (direction start PAGESIZE)

  "Data request error handler"
  (.log js/console (str "something went wrong: " status " " status-text)))


(defn fetch [url]
  "Get data from URL"
  (GET url {:handler handler

           (println "Fetched data from DB")
           (let [data (.parse js/JSON resp)]
           (updatedb [:data] (js->clj data))))))

(defn data_to_db [url]
  "Send data to db"
  (.write js/crud url (.stringify js/JSON (clj->js (:data db)))))

(defn setpage [next]
  (updatedb [:start] next))
