fix racy condition