refractored save json