Length conversion logic