refactored data access