replace shallow clone with deep clone