This looks OK. I suppose the problem was if domain was an array?