diff --git a/app/controllers/habits_controller.rb b/app/controllers/habits_controller.rb
index ce82289f24edb26b88ebe39f6bc1cb31cd9f5791..fc54465355dcfca47e48a9029e67cfc5ac429f53 100644
--- a/app/controllers/habits_controller.rb
+++ b/app/controllers/habits_controller.rb
@@ -85,7 +85,7 @@ class HabitsController < ApplicationController
       end
     end
 
-    if @habit.streak > @habit.max_streak || @habit.max_streak.nil?
+    if @habit.max_streak.nil? || @habit.streak > @habit.max_streak
       @habit.max_streak = @habit.streak
       @habit.save
     end