fix invalid thread access