Broke initial code in main.cpp into two functions