As suggested to me by Nic, I think you can use groovys multiple assignment operator to avoid a lot of this temp variable business. http://groovy.codehaus.org/Multiple+Assignment