optimalDomain.R file updated but not yet finished