copy the parameters to avoid modifying the input array objects