Attempting to fix possible race condition