Begin lengthData function