add json pretty printer and refactor