fix the separate thread issue