refactor to use new json protocol