fix the logic for filtering list