#11 added check for array before calling replacement function apply/call
[ci skip]