Refactor debug_mode condition for localization