refactor db provider