Fixed bug in thread.