minor edits to sql