refactoring data access