refactoring filtering sensor as function