enhance filtering logic