test & implement the filter function of loops