Refactored view model to make it cleaner