Fixed the race condition once and for all