thread failing with weird error