printMainPAge refactored