factored out common code to tutorial_utils.py