add getLength method.