moved main block to main()