use typeof to check undefined