translated Example 6 to Groovy