Refactoring view-model code relationship