replaced java by groovy, moved code to Util classes