refactor print method