fix race condition
Merge pull request #36 from yingted/master

fix race condition