refactor sqlprovider