Fix undefined check

You check the value undefined not the string value "undefined"