Replace indexing into the os.environ dictionary with a .get() call (and a default) to avoid an IndexError