change to using thread.join()