refactored state filter