decomposed main.cpp into smaller files to be more readable