Fix undefined check

You check the value undefined not the string value "undefined"
Merge pull request #699 from throrin19/patch-1

Fix undefined check