refactor the filter algorithms