Repository pattern refactoring