this isthe second version of filtering script