finished the filter algorithm
s