Changed shallow copy to deep copy