Extended the filter function