diff --git a/featured_content.module b/featured_content.module
index 0fcfa39..f1ebee3 100644
--- a/featured_content.module
+++ b/featured_content.module
@@ -1551,10 +1551,10 @@ function featured_content_sort_nodes_by_terms($nodes, $order = 'desc') {
     );
     //while ($row = db_fetch_object($results)) {
     foreach ($results as $row) {
-      $tmp[$row->nid] = $node[$row->nid];
+      $tmp[$row->nid] = $nodes[$row->nid];
     }
     foreach ($nodes as $nid => $node) {
-      if (! in_array($nid, $tmp)) {
+      if (! isset($tmp[$nid])) {
         // tack on the rest of the nodes
         $tmp[$nid] = $node;
       }
