simplify 2 if-else cases in main.cpp