fixing race condition
Fixing race condition