Refactored code to move print logic into MessageManager