Use array_map instead of foreach loop