diff --git a/src/textswitch.js b/src/textswitch.js
index 3ae72322cfbc18353ad35e43ae790a4818e8e6e0..1bb52364b0f2675fba20a051b9110e30444f9760 100644
--- a/src/textswitch.js
+++ b/src/textswitch.js
@@ -59,12 +59,18 @@ export class TextSwitch extends LitElement {
     }
 
     update(changedProperties) {
+        if (this._active === BUTTON1) {
+            this.name = this.name1;
+        } else {
+            this.name = this.name2;
+        }
+
         changedProperties.forEach((oldValue, propName) => {
             if (propName === "name") {
-                if (this[propName] == this.name1) {
+                if (this[propName] === this.name1) {
                     this._active = BUTTON1;
                 }
-                if (this[propName] == this.name2) {
+                if (this[propName] === this.name2) {
                     this._active = BUTTON2;
                 }
             } else if (propName === "_active") {
@@ -76,12 +82,6 @@ export class TextSwitch extends LitElement {
             }
         });
 
-        if (this._active === BUTTON1) {
-            this.name = this.name1;
-        } else {
-            this.name = this.name2;
-        }
-
         super.update(changedProperties);
     }