diff --git delete_orphaned_terms.module delete_orphaned_terms.module
index 61f1de5..2c17420 100644
--- delete_orphaned_terms.module
+++ delete_orphaned_terms.module
@@ -71,13 +71,16 @@ function _dot_get($var) {
  */
 function __delete_orphaned_terms_tax_term_count_entities($tid, $count = TRUE) {
   $cnt = 0;
-  $conditions = array(array('tid', $tid));
 
   $instances = field_read_instances();
   foreach ($instances as $instance) {
     // check if this has to do with taxonomy, otherwise there will be no 'tid' column
     if ($instance['widget']['module'] == 'taxonomy') {
-      $cnt += field_attach_query($instance['field_id'], $conditions, array('count' => $count));
+      $field = field_info_field_by_id($instance['field_id']);
+      $query = new EntityFieldQuery();
+      $query->fieldCondition($field, 'tid', $tid)
+        ->count();
+      $cnt += $query->execute();
     }
   }
 
@@ -104,11 +107,13 @@ function _delete_orphaned_terms_voc_is_tag($vid) {
 
   $terms = taxonomy_get_tree($vid);
   foreach ($terms as $term) {
-    $conditions = array(array('tid', $term->tid));
     foreach ($fi_auto as $fi) {
       // if a field exists for that term and in the previously compiled list,
       // then we have a tagging term
-      $ok = field_attach_query($fi['field_id'], $conditions);
+      $field = field_info_field_by_id($fi['field_id']);
+      $query = new EntityFieldQuery();
+      $query->fieldCondition($field, 'tid', $term->id);
+      $ok = $query->execute();
       if (!empty($ok)) {
         $ret = TRUE;
         break 2;
