Fix issue with index() raising error when value not found.