handle racing condition