implement filter function with two condition