make sure thread.join() is used completely here