generalizing iteration count