fixing a race condition

My previous PR introduced a race condition.  Now when flags is initialized, if it has already updated it will return a resolved promise, but if it is in the process of updating it will return the original promise.