fix the many threads issue