The length check should be kept here to avoid possible buffer overflows.