early termination detection added