Fixed off-by-one error in selecting the initial index.