Fixed a bug when startlength isn't 0.