Added function to handle printing