Fix error with threads