diff --git a/visualizer.py b/visualizer.py
index 73f5f56a1ea32f06ced96696a917746a80320629..62c9a7eb45979032052334d5f1bd0b330614968f 100755
--- a/visualizer.py
+++ b/visualizer.py
@@ -90,19 +90,19 @@ matplotlib.use('Agg')
 
 @app.route('/')
 def home():
-    g.stations = read_stations()
+    populate_g()
     return render_template('index.html')
 
 
 @app.route('/overlay')
 def overlay():
-    g.stations = read_stations()
+    populate_g()
     return render_template('overlay.html')
 
 
 @app.route('/boxplot')
 def boxplot():
-    g.stations = read_stations()
+    populate_g()
     return render_template('boxplot.html')
 
 
@@ -301,6 +301,11 @@ def savefig_response(fig):
     return Response(buf.getvalue(), mimetype='image/png')
 
 
+def populate_g():
+    """Populate `g` with data for rendering page templates."""
+    g.stations = read_stations()
+
+
 def read_stations():
     """Read amrdcrecords.json."""
     with open('amrdcrecords.json') as f: