Added the filtering logic