Updated snippet with setDomain method