Fix the race condition