fix thread hanging