minor bug fix if length == 0