additional filtering logic and cleanup