     (-> state
         (assoc :selected-eid group-id)
         (assoc-in [:drawing :original-layers] (conj layers group-layer))
-        (assoc-in [:drawing :layers] (conj (mapv (fn [layer entity-id]
+        (assoc-in [:drawing :layers] (conj (mapv (fn [layer entity-id index]
                                                    (assoc layer
                                                      :points (when (:layer/path layer) (parse-points-from-path (:layer/path layer)))
                                                      :db/id entity-id

                (update-in [:entity-ids] disj entity-id))]
            r)))

(defn inc-str-id [str-id]
  (if-let [[match base num] (re-find #"(.+)\((\d+)\)" str-id)]
    (str base "(" (inc (js/parseInt num)) ")")
    (str str-id " (1)")))

(defmethod control-event :layer-duplicated
  [browser-state message {:keys [layer x y]} state]

                                        :layer/current-x (:layer/end-x layer)
                                        :layer/current-y (:layer/end-y layer)
                                        :layer/ui-id (when (:layer/ui-id layer)
                                                       (inc-str-id @(:db state) (:layer/ui-id layer)))
                                        :layer/ui-target (when (:layer/ui-target layer)
                                                           (inc-str-target @(:db state) (:layer/ui-target layer))))])
        (assoc-in [:drawing :moving?] true)
        (assoc-in [:drawing :starting-mouse-position] [rx ry])
        (update-in [:entity-ids] disj entity-id))))
