made filtering function more applicable