Fixed check for undefined