Fixing race condition for state loading