Refactored: introduced dialog to declutter main()