bug in length computation