fix async script race condition