Added multi threading for query execution