Fix race condition

Signed-off-by: Georg Apitz <gapitz@pivotal.io>