Refactoring data access