refactor to database provider