Merge two if conditions in main()