refactor vm