Moved logic to viewModel