cleanup of printing code