filter implementation & refactoring