Refactor compareIterations to remove duplicate code.