Length calculation on demand