diff --git a/habit.php b/habit.php
index 671e6a8..2f9e6ee 100644
--- a/habit.php
+++ b/habit.php
@@ -391,18 +391,24 @@
 	}
 
 	
-    $streak = 0;
-	$thisWeek = date('Y-W'); // Get the current week
+    $consecutiveCount = 0;
+    $maxConsecutiveCount = 0;
 
-	while (isset($weeklyOccurrences[$thisWeek]) && $weeklyOccurrences[$thisWeek] >= $multiplier) {
-	    $streak++;
-	    $thisWeek = date('Y-W', strtotime($thisWeek . ' -1 week'));
-	}
+    ksort($weeklyOccurrences); 
+
+    foreach ($weeklyOccurrences as $week => $value) {
+        if ($value >= 2) {
+            $consecutiveCount++;
+            $maxConsecutiveCount = max($maxConsecutiveCount, $consecutiveCount);
+        } else {
+            $consecutiveCount = 0; // Reset count if the value is less than 2
+        }
+    }
 
   	//print_r($dateOccurrences);
     //print_r($weeklyOccurrences);
 
-    return $streak;
+    return $consecutiveCount;
 }
 
 function habit_get_stat_missed($word, $filename) {