fix thread problem