Functionized main.cpp