Fix thread variable error