Refactoring vm and add implicit cast to value