Finally coded convert using the mergeTable function