diff --git a/inc/fulltext.php b/inc/fulltext.php
index 8155325ee7df5b1bda7d6724ef987d768a197ee1..d2fbabe770eb4dae378bdffa055e112d94d14ee7 100644
--- a/inc/fulltext.php
+++ b/inc/fulltext.php
@@ -241,11 +241,11 @@ function _ft_pageLookup(&$data){
             }
         }
     }
+
     if (isset($ns)) {
-        foreach ($page_idx as $p_id) {
-            if (strpos($p_id, $ns) === 0) {
-                if (!isset($pages[$p_id]))
-                    $pages[$p_id] = p_get_first_heading($p_id, false);
+        foreach (array_keys($pages) as $p_id) {
+            if (strpos($p_id, $ns) !== 0) {
+                unset($pages[$p_id]);
             }
         }
     }