ported to Groovy