refactored filter part