add validation and refactor the print interface