use typeof to check for undefined