Refactored filtering