Reestructuring main.cpp file