Refactor measurement to reduce complexity.