Correcting length calculation