refactor to groovy way