you can use ``array_intersect_key`` instead to implement all the logic at once