Fix for possible race condition