Fix commitWithin() logic