some refactoring on the client and spase JSON