moving filtering logic to helper