diff --git a/templates/trip/stats.html b/templates/trip/stats.html
index 8a117ef..7d81a3d 100644
--- a/templates/trip/stats.html
+++ b/templates/trip/stats.html
@@ -31,20 +31,24 @@
       {% endfor %}
       </div>
     <div>
-      Flight segments in {{ year }}: {{ year_stats.flight_count }}
+      Flight segments in {{ year }}: {{ year_stats.flight_count or 0 }}
+      {% if year_stats.airlines %}
       [ by airline:
-      {% for airline, count in year_stats.airlines.most_common() %}
-        {{ airline }}: {{ count }}{% if not loop.last %},{% endif %}
-      {% endfor %} ]
+        {% for airline, count in year_stats.airlines.most_common() %}
+          {{ airline }}: {{ count }}{% if not loop.last %},{% endif %}
+        {% endfor %} ]
+      {% endif %}
     </div>
-    <div>Trains segments in {{ year }}: {{ year_stats.train_count }}</div>
-    <div>Total distance in {{ year}}: {{ format_distance(year_stats.total_distance) }}</div>
+    <div>Trains segments in {{ year }}: {{ year_stats.train_count or 0 }}</div>
+    <div>Total distance in {{ year}}: {{ format_distance(year_stats.total_distance or 0) }}</div>
+    {% if year_stats.distances_by_transport_type %}
     {% for transport_type, distance in year_stats.distances_by_transport_type.items() %}
       <div>
         {{ transport_type | title }}
         distance: {{format_distance(distance) }}
       </div>
     {% endfor %}
+    {% endif %}
   {% endfor %}
 </div>
 {% endblock %}