Ziqi added functions in main()