Refactor Repository pattern implementation