diff --git a/flatland/core/env.py b/flatland/core/env.py
index d6493507c5d3cea79e86e795348cf3ef70f5216f..950365fd52fffca27b3a1f118d910628533cb41d 100644
--- a/flatland/core/env.py
+++ b/flatland/core/env.py
@@ -244,10 +244,10 @@ class RailEnv:
                 if movement >= 4:
                     movement -= 4
 
+                is_deadend = False
                 if action == 2:
                     # compute number of possible transitions in the current
                     # cell
-                    is_deadend = False
                     nbits = 0
                     tmp = self.rail.get_transitions((pos[0], pos[1]))
                     while tmp > 0: