adds filtering logic