refactoring data access layer