better handling for json marshalling