use switch instead of if for vm part