TypetoVar now correctly handles dynamic variables and variables declared in a for loop