Fix reindex logic