threading added for query execution