serialize state as well