greatly simplify main()