Added boolean for early termination