refactor groovy interrupt code