fix the use of thread