diff --git a/src/Tokenizer/Tokens.php b/src/Tokenizer/Tokens.php
index <HASH>..<HASH> 100644
--- a/src/Tokenizer/Tokens.php
+++ b/src/Tokenizer/Tokens.php
@@ -313,13 +313,14 @@ class Tokens extends \SplFixedArray
 
         if (!$this[$index] || !$this[$index]->equals($newval)) {
             $this->changed = true;
-        }
 
-        if (isset($this[$index])) {
-            $this->unregisterFoundToken($this[$index]);
+            if (isset($this[$index])) {
+                $this->unregisterFoundToken($this[$index]);
+            }
+
+            $this->registerFoundToken($newval);
         }
 
-        $this->registerFoundToken($newval);
         parent::offsetSet($index, $newval);
     }
DX: Tokens - do not unregister/register found tokens when it is the same token