making width be calculated from either header length or data length