Fixed undefined check.

Forgot I had to explicitly check the type of variable type to see if it's undefined.