fix multi-thread problem