Refactored ViewModel to use repository pattern