be smarter about when to save state