modularized main()