fix main thread bug