filter array by using predicate instead iterating