Implement ensure-index properly