I would put all of this module-level code in main()