minor edit to sql queries