Function that copies tables