tweaks to sql