this piece of code appears in many place. It could be refactored with a static using `array_walk`