refactored addFilter method