length calculation added