getLength() bug fix