GI code for 'both' model. Fix to earlier R code.