Improved main.cpp