write state to json too