add the merge and extend function