fixed bug, second arg is length not end point