replace terminate with group