diff --git a/synonyms.module b/synonyms.module
index b17262c86dda7393c8a4d831cdea93bfcafa425e..b40149f2a4399d085c0df9c15476861c7f322a1e 100644
--- a/synonyms.module
+++ b/synonyms.module
@@ -31,12 +31,17 @@ function synonyms_taxonomy_vocabulary_insert($vocabulary) {
  *   An array containing all synonyms of the given term id.
  */
 function synonyms_get_synonyms($tid) {
+	$synonyms = array();
   if ($tid) {
-    return db_query('SELECT synonyms_synonym_value FROM {field_data_synonyms_synonym} WHERE entity_id = :tid', array(':tid' => $tid))->fetchCol();
-  }
-  else {
-    return array();
+		$term = taxonomy_term_load($tid);
+		$synonyms_synonym = field_view_field('taxonomy_term', $term, 'synonyms_synonym');
+		if(isset($synonyms_synonym['#items'])){
+			foreach ($synonyms_synonym['#items'] as $delta => $synonym) {
+				$synonyms[] = $synonym['value'];
+			}
+		}
   }
+	return $synonyms;
 }
 
 /**
@@ -48,10 +53,14 @@ function synonyms_get_synonyms($tid) {
  * @return
  *  An array of term objects containing that synonym. 
  */
-function synonyms_get_synonym_root($synonym) {
-    $tids = db_query('SELECT tid FROM {field_data_synonyms_synonym} s, {taxonomy_term_data} t WHERE t.tid = s.entity_id AND s.synonyms_synonym_value = :name', array(':name' => $synonym))->fetchCol();
-    $terms = taxonomy_term_load_multiple($tids);
-    return $terms;
+function synonyms_get_synonym_root($synonym) {		
+		$query = new EntityFieldQuery;
+		$result = $query
+			->entityCondition('entity_type', 'taxonomy_term')
+			->fieldCondition('synonyms_synonym', 'value', $synonym, '=')
+			->execute();
+		
+    return isset($result['taxonomy_term']) ? $result['taxonomy_term'] : array();
 }
 
 /**
@@ -60,30 +69,21 @@ function synonyms_get_synonym_root($synonym) {
  * Ensures that synonyms are included when indexing a node
  */
 function synonyms_node_update_index($node) {
- // Get a list of all term reference fields attached to this node type
-  $term_reference_fields = db_query(
-    "SELECT fc.field_name
-     FROM {field_config_instance} fci
-     JOIN {field_config} fc ON fci.field_id = fc.id
-     WHERE fci.bundle = :type
-     AND fc.type = 'taxonomy_term_reference'", array(':type' => $node->type))->fetchCol();
+	#get the fields defenition of node type
+	$type_fields = field_info_instances('node');
 
-  $synonyms = array();
-  // Loop through each vocabulary attached to this node type
-  foreach ($term_reference_fields as $term_reference_field) {
-    // Check if the node contains any taxonomy terms from this vocabulary
-    if ($node->nid > 0 && !empty($node->$term_reference_field)) {
-      // Get the vocabulary object
-      $taxonomy_tags = $node->$term_reference_field;
-      // Loop through each term attached to the node
-      foreach ($taxonomy_tags['und'] as $term) {
-        // Loop through each synonym of this term and add them to the array
-        foreach (synonyms_get_synonyms($term['tid']) as $synonym) {
-          $synonyms[] = $synonym;
-        }
-      }      
-    }
-  }
+	$synonyms = array();
+	foreach ($type_fields[$node->type] as $field_name => $field) {
+		$fieldinfos = field_info_field($field_name);
+		if($fieldinfos['type'] == 'taxonomy_term_reference'){
+			$terms = field_view_field('node', $node, $field_name);
+			if(isset($terms['#items'])){
+				foreach ($terms['#items'] as $delta => $term) {
+					$synonyms = array_merge($synonyms, synonyms_get_synonyms($term['tid']));
+				}
+			}
+		}
+	}
   if (!empty($synonyms)) {
     return '<strong>(' . implode(', ', $synonyms) . ')</strong>';
   }
