improve json input and output