You're calling `GetInstancePersistenceState` twice in a row here, when there is state. Store it to a variable and check the variable instead.