rewrote main()