Instead of copying each element of the array on its own, swap the pointers for h and h_new