Oh... copyout already did the work... although my function is better.