small refactor in main()