Using copy in the auxiliar function. Dont know if the new code is
slower than the previous one