length search now does n instead of n-1