factor out print functions