Improved print method for pretty printing