diff --git a/controllers/gddAccumulatedController.js b/controllers/gddAccumulatedController.js
index e00ef0c12513b4d4ecfaf54fd384b41bdd5bcff5..5be4c73d7accae46b62e2ecad0179704b99777ed 100644
--- a/controllers/gddAccumulatedController.js
+++ b/controllers/gddAccumulatedController.js
@@ -27,9 +27,8 @@ function find(collection, query, projection, temps, res) {
         var gdd_sum = 0;
         
         for (var i = 0; i < min_temps.length; i++) {
-            min_temp = min_temps[i] >= t_min ? min_temps[i] : t_min;
-            max_temp = max_temps[i] <= t_max ? max_temps[i] : t_max;
-            gdd_sum += ((max_temp + min_temp) / 2) - t_base
+            gdd = utils.calculate_gdd(min_temps[i], t_min, max_temps[i], t_max, t_base);
+            gdd_sum += gdd
             gdds.push(gdd_sum)
         }
         send_response("Accumulated GDDs", gdds, data, res);
diff --git a/controllers/gddController.js b/controllers/gddController.js
index f0d9bd02567fdafbe022a5298147988fcf0f920b..095c6842788f6c59c6194312a9502215a686860a 100644
--- a/controllers/gddController.js
+++ b/controllers/gddController.js
@@ -26,10 +26,8 @@ function find(collection, query, projection, temps, res) {
         var max_temp = 0
         
         for (var i = 0; i < min_temps.length; i++) {
-            min_temp = min_temps[i] >= t_min ? min_temps[i] : t_min;
-            max_temp = max_temps[i] <= t_max ? max_temps[i] : t_max;
-
-            gdds.push(((max_temp + min_temp) / 2) - t_base)
+            gdd = utils.calculate_gdd(min_temps[i], t_min, max_temps[i], t_max, t_base);
+            gdds.push(gdd)
         }
         send_response("GDDs", gdds, data, res);
     }, function(err) {
diff --git a/controllers/gddNormalController.js b/controllers/gddNormalController.js
index 349dba5eefd471650efcc80feeb3b1ff6cf04e36..638e871851059a0d824ef0a60784b9effbad3329 100644
--- a/controllers/gddNormalController.js
+++ b/controllers/gddNormalController.js
@@ -13,9 +13,9 @@ function find(collection, query, projection, temps, res) {
         var max_temp = 0
 
         for (var i = 0; i < min_temps.length; i++) {
-            min_temp = min_temps[i] >= t_min ? min_temps[i] : t_min;
-            max_temp = max_temps[i] <= t_max ? max_temps[i] : t_max;
-            gdds.push(((max_temp + min_temp) / 2) - t_base)
+            gdd = utils.calculate_gdd(min_temps[i], t_min, max_temps[i], t_max, t_base);
+
+            gdds.push(gdd)
         }
 
         res.json({
diff --git a/lib/utils.js b/lib/utils.js
index 45ec42631fb2df0b1131dc9c0be6c258da56fa6e..b450a8fd753a5876724e235cabeef7c93a857355 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -41,4 +41,14 @@ function product_base_switch(product, errors, t_base, t_min) {
     }
 }
 
-module.exports.product_base_switch = product_base_switch;
\ No newline at end of file
+
+function calculate_gdd(min_temp, t_min, max_temp, t_max, t_base) {
+    min_temp = min_temp >= t_min ? min_temp : t_min;
+    max_temp = max_temp >= t_min ? max_temp : t_min;
+    max_temp = max_temp <= t_max ? max_temp : t_max;
+    gdd = ((max_temp + min_temp) / 2) - t_base;
+    return gdd
+}
+
+module.exports.product_base_switch = product_base_switch;
+module.exports.calculate_gdd = calculate_gdd;
\ No newline at end of file