moved model logic to view model