Fix in getLength function