Add end index as the 4th parameter to groovy scripts.