Since this is done in two separate scripts, it should be factored out.