added undefined check for domain