fix multi-thread bug