   (into []
         (map txn/hash-txn [(coinbase)])))
 
-(def mine? (atom true))
+(defonce mine? (atom true))
 (defn stop-miner! [] (reset! mine? false))
 
 (defn mine-block
   ([] (mine-block (generate-block (gather-transactions))))
   ([pending]
    (println "****** Will Mine Block: ******\n" pending "\n***************************")
-   (let [b (mine pending mine?)]
-     (println "****** Successfully Mined Block: ******\n" b "\n***************************")
-     (bc/add-block! b))))
+   (if-let [b (mine pending mine?)]
+     (do (println "****** Successfully Mined Block: ******\n" b "\n***************************")
+         (bc/add-block! b))
+     (println "didn't find coin, exiting"))))
 
 (defn run-miner! []
   (reset! mine? true)

(defn adjusted-target [blocks frequency]
  (let [times (map #(get-in % [:header :timestamp]) blocks)
        latest-target (get-in (last blocks) [:header :target])
        ratio (/ frequency (avg-spacing times))]
    (hex-string (bigint (* ratio
                           (hex->int latest-target))))))

(defn next-target

  []
  (let [recent-blocks (take-last 10 @bc/block-chain)]
    (if (and recent-blocks (> (count recent-blocks) 5))
      (adjusted-target recent-blocks 15)
      (hex-string (math/expt 2 237)))))

(defn generate-block
  [transactions]
