Fixing early termination issue