refactored the viewModel and wrote tests for it