             (.contains station-name input)
             (.contains system-name input))))
       (get-stations))))
+
+(defn- exists? 
+  "Conveniently get a true/false value if an arg exists"
+  [arg]
+  (or (= true arg)
+      (not (nil? arg))))
+
+(defn- arg-value 
+  "Provide a safe default value if none is provided"
+  [arg]
+  (if (nil? arg)
+    "1"
+    arg))
 
 ;;
 ;; API calls

  "http://www.elitetradingtool.co.uk/api/EliteTradingTool/Calculator")
(def search-url 
  "http://www.elitetradingtool.co.uk/api/EliteTradingTool/Search")

;;
;; Util methods
;;

(defn on-search
  "Packet handler for :search"
  [ch packet]
  (if-let [system (:system packet)]
    ; NB this also seems overly complicated
    (apply search-stations
           (flatten (conj [system] 
                          (calculate-packet-to-seq packet)
                          :callback #(to-client ch {:type :search-result
                                                    :result %}))))
    (client-error ch "Must specify system")))

;;
