try to fix "undefined" bug

now replace
x==undefined with typeof(x)=="undefined"