refactored pretty-printing