Refactor viewmodel.