refactored filtered code