fix index off-by-one error.