diff --git a/dfp.module b/dfp.module
index 0c92dea..242f7b3 100644
--- a/dfp.module
+++ b/dfp.module
@@ -164,16 +164,18 @@ function dfp_block_view($delta) {
 function dfp_entity_view($entity, $type, $view_mode, $langcode) {
   $dfp_targeting_terms = &drupal_static('dfp_entity_targeting_terms', array());
 
-  if ($view_mode == 'full') {
+  if (variable_get('dfp_enable_ad_categories', 0) && $view_mode == 'full') {
     // Find all taxonomy terms attached to the given entity and add them to the
     // dfp_targeting_terms array. Check each term to see if a DFP Ad Category
     // has been assigned to it. If so, add that term to the array instead.
     foreach (element_children($entity->content) as $key) {
       if (isset($entity->content[$key]['#field_type']) && $entity->content[$key]['#field_type'] == 'taxonomy_term_reference') {
         $terms = field_view_field($type, $entity, $key);
-        foreach ($terms['#items'] as $item) {
-          if (array_key_exists('taxonomy_term', $item)) {
-            $dfp_targeting_terms[] = _dfp_get_ad_category($item['taxonomy_term'], TRUE);
+        if (isset($terms['#items']) && is_array($terms['#items'])) {
+          foreach ($terms['#items'] as $item) {
+            if (array_key_exists('taxonomy_term', $item)) {
+              $dfp_targeting_terms[] = _dfp_get_ad_category($item['taxonomy_term'], TRUE);
+            }
           }
         }
       }
