added deep functionality to extend()