moved function initialization outside of main()