thread bug fix