clean up with thread first