I just made this replacement for optimization. Different approaches are possible here. As the optional parameter is only expected to be an array, maybe we could just remove this check?