reurganization of main()