add terminate condition