fixed bug in main()