Rearranged main.cpp