refactor print