         options (into settings options)]
     (ant Scp options)))
 
+(defn- get-key-options
+  "check the project options for a keyfile"
+  []
+  (seq (map file (filter #(not (nil? %))
+                         (map #(-> % opts first)
+                              [:i :identity])))))
 
-;check here, can probably get rid of the when-let wierdness if you make these fns return a string
-(comment defn- get-key-setting
+(defn get-key-setting
   "look for a keyfile specified in options or config"
-  [& [env]]
-  (when-let [path (or (first (or (map #(get opts %) [:i :identity])))
-                      (when env (get config (str env ".keyfile"))))]
-    [(file path)]))
+  [env]
+  (when-let [kf (get config (str env ".keyfile"))]
+    [(file kf)]))
 
-(defn- get-key-setting
-  "look for a keyfile specified in options or config"
-  [& [env]]
-  (or (seq (filter #(not (nil? %))
-                   (map #(-> % opts first)
-                        [:i :identity])))
-      (seq (when env (get config (str env ".keyfile"))))))
-
-(defn- detect-keys
+(defn get-keys-in
   "look for id_rsa, id_dsa, or identity in path"
   [path]
   (seq (filter #(.exists %)
                (map #(file (java.io.File. path) ".ssh" %)
                     ["id_rsa" "id_dsa" "identity"]))))
 
-(defn- find-keys [& [env]]
-  (let [keys (or (let [x (get-key-setting env) foo (println "x:" x)] x)
-                 (detect-keys (System/getProperty "user.home")))]
+(defn find-keys [& [env]]
+  (let [keys (or (get-key-options)
+                 (when env (get-key-setting env))
+                 (get-keys-in (System/getProperty "user.home")))]
     (when keys (apply println "Using keyfiles:" (map #(-> % .toString .trim) keys)))
     keys))
 
-(defn- transfer
+(defn try-scp
   ([user source dest keys passphrase]
      (doseq [key keys :while (not @*success*)]
        (print (.toString key) "...")


(def *success* (atom false))

(defn- scp
  "call the scp ant task with options"
  [user to-file to-path & options]
  (let [settings {:trust true

       (catch org.apache.tools.ant.BuildException e
         (println "Incorrect Password.")))))

(defn merge-settings [{env :env :as settings}]
  (let [defaults {:user (or (get config (str env ".user"))
                            (System/getProperty "user.name"))
                  :keys (find-keys env)
                  :passphrase (when (:p opts) (prompt-read "Enter passphrase"))}]
    (merge defaults settings)))

(defn deploy*
  [settings]
  (let [{:keys [user source hosts path keys passphrase]} (merge-settings settings)]
    (doseq [host hosts]
      (let [dest (str host ":" path)]
        (println "Attempting to copy:" (.toString source) "to" dest)
        (try-scp user source dest keys passphrase)
        (when-not @*success*
          (when (and keys (not (:p opts)))
            (println "All keyfiles failed, if a keyfile passphrase is required, use the -p flag"))
          (try-scp user source dest))))))

(defn deploy [& args]
  (if (vector? (first args))
