Refactored data layer