Fix an issue with indices after filtering