corrected length calculation