refactor virtual machine