                (v2-add bez3 (v2-scale alpha2 tan2))
                bez3))))
 
-(def fit-error 4.0)
+(def fit-error 16.0)
+(def adjust-error 4.0)
+(def max-adjust-iter 10)
 
 (defn compute-max-error [coords bezier params]
   (->>

    (reduce (fn [[max-dist split-point :as res-pair] [i dist]]
              (if (>= dist max-dist) [dist i] res-pair))
            [0.0 (/ (count coords) 2)])))

(defn fit-cubic
  ([coords]

    (if (= (count coords) 2)
      ; use the heuristic if there are no intermediate points
      [(wu-barsky-heuristic (first coords) (last coords) tan1 tan2)]
      (let [params (chord-parameterize coords)
            bezier (gen-bezier coords params tan1 tan2)
            [max-error split-point] (compute-max-error coords bezier params)]
        (if (< max-error fit-error)
          [(adjust-bezier bezier coords params tan1 tan2
                          adjust-error max-adjust-iter)]
          (let [center-tan (v2-center-tangent
                             (nth coords (dec split-point))
                             (nth coords split-point)
