Updated code to have both deep and shallow copying