Minor changes to sql statement