added function to complete whole queries