change finished query execution detection method