Refactor print functions