refactored pretty-printing output