Moved logic to vm.