code from meetup
attempt to rewrite code from meetup in groovy