modified calculation of length