Printer code refactoring