Fixed check on undefined