reimplement filtering with list of indices