looks good, but we should move the `allowed_len is not None` check outside the loop as it won't change each iteration