implemented filter function