Extract text string then placed on attribute

Good day everyone,

This is a code that lets me extract the text then placed it on attribute, however when I do, it places the text to some other text and not on the designated attribute. Does anyone know how to fix it? If possible, can I also do it on just one go? Maybe I can select the text strings in order then it will automatically populate my template. I know that's a bit much, if it cannot be done, I'm good with selecting the text strings then choose the attribute it was designated to or the other way around. Thank you very much in advance.
 

(defun c:TEXTRACT ()
 (setq ent (car (entsel "\\nSelect the text: ")))
 (setq text (cdr (assoc 1 (entget ent)))) ; Get the text content
 ; Customize your attribute names here:
 (setq att1 "DN")
 (setq att2 "MT")
 ; Set the attribute values
 (entmod (subst (cons 1 (substr text 1 (vl-string-search "\\\\P" text))) (assoc 1 (entget (entnext ent))) (entget (entnext ent))))
 (entmod (subst (cons 1 (substr text (+ (vl-string-search "\\\\P" text) 2))) (assoc 1 (entget (entnext (entnext ent)))) (entget (entnext (entnext ent)))))
 (princ "Text extracted and assigned to custom attributes.")
)