fix possible race condition
simpler part working