complete filter function.