refactored if/else logic in main()