some testing and modifications in main()