added undefined type checks