state saving is fragile, but seems to work