diff --git a/content_taxonomy_autocomplete.module b/content_taxonomy_autocomplete.module
index 9099e9a..e044192 100644
--- a/content_taxonomy_autocomplete.module
+++ b/content_taxonomy_autocomplete.module
@@ -403,7 +403,7 @@ function content_taxonomy_autocomplete_merge_tags($terms, $vid) {
   if (!empty($terms)) {
     foreach ($terms as $term) {
       // Extract terms belonging to the vocabulary in question.
-      if ($term->vid == $vid) {
+      if (!empty($term) && $term->vid == $vid) {
         //if ($tid && in_array($term->tid,drupal_map_assoc(array_keys((taxonomy_get_children($tid,$vid)))))) {
           // Commas and quotes in terms are special cases, so encode 'em.
           $name = $term->name;

