Fixing race condition

Change-Id: I5a298d97c3723a567c4d5a64638f5114c791954b