Reorganized to use main()