threshold filter & refactoring.