Fixed main thread check