updated the clone() method to support deep clones