                                         :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 (:layer/ui-id layer)))
+                                                       (inc-str-id @(:db state) (:layer/ui-id layer)))
                                         :layer/ui-target (when (:layer/ui-target layer)
-                                                           (inc-str-id (: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))))

    (-> 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 layer
                                                     :points (when (:layer/path layer) (parse-points-from-path (:layer/path layer)))
                                                     :db/id entity-id

                                                     :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) :offset index))
                                                     :layer/ui-target (when (:layer/ui-target layer)
                                                                        (inc-str-target @(:db state) (:layer/ui-target layer) :offset index))))
                                                 layers entity-ids (range))
                                           group-layer))
        (assoc-in [:drawing :moving?] true)
        (assoc-in [:drawing :starting-mouse-position] [rx ry])
