add to sql refactoring