reusing code from vm