removed prototype declaration; moved function definition before main()