decomposed main.cpp into several files by class functions
to make the code more readable