more robust handling of state changes