Fix thread issue