editing the code from feedback on vm-3 branch