fixed racing condition