fix race condition issue #3