Fix the multi-thread func