adopted changes to sql queries